//
// C++ Interface: object
//
// Description: 
//
//
// Author: Os3 s.r.l. <xgui@os3.it>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifdef SWIGPYTHON
	%typemap(in, numinputs=0) std::string &dest (std::string temp) {
		$1 = &temp;
	}

	%typemap(argout) std::string &dest {
		Py_XDECREF($result);
		if (result) {
			char const * cstrdata = $1->c_str();
			unsigned long int cstrlen = $1->size();
			$result = PyString_FromStringAndSize(cstrdata, cstrlen);
		}
		else {
			Py_INCREF(Py_None);
			$result = Py_None;
		}
	}

	%typemap(out) xgui::Object * { $result = XGUIPyObjectCreate($1, false); }
#endif

namespace xgui
{
	struct StoredObject;
	
    %feature("docstring","**DESCRIPTION**\n\nderives from :class:`xgui.ClassInfo`\n\n") ObjectClass;
	struct ObjectClass : public xgui::ClassInfo
	{
		ObjectClass();
		xgui::Object * create(xgui::Object * parent, xgui::StringMap &properties);
		void finalize(xgui::Object *);

		virtual bool canContain(xgui::ClassInfo * c);
		virtual bool canBeContainedIn(xgui::ClassInfo * c);
	
		bool isInstanceable();
		bool mustFinalize();
		virtual std::string const &className();
		bool isContainer();
		bool isWidget();
		bool isModel();
		bool isStyleManager();
	};
    %feature("docstring","**PROPERTIES**\n\n* **id** *(RW):* sets or retrieves the object ID \n\n**METHODS**\n\n") Object;
	class Object
	{
		protected:
			Object(xgui::ClassInfo * cinfo);
			virtual ~Object();

		public:
			//Dynamic type management
			%feature("docstring","returns the name of the class this object belongs to\n\n*C++*::\n\n std::string const &className();\n\n") className;
			std::string const &className();
			%feature("docstring","returns a pointer to a ClassInfo structure that represents the object class.\n\n*C++*::\n\n xgui::ClassInfo *getClass();\n\n") getClass;
			xgui::ClassInfo *getClass();
            %feature("docstring","returns true if the object's id is equal to the specified id; false otherwise\n\n*C++*::\n\n bool isIdentifiedAs(std::string const &id);\n\n") isIdentifiedAs;
			bool isIdentifiedAs(std::string const &id);
			%feature("docstring","returns the object's id\n\n*C++*::\n\n std::string const &id();\n\n") id;
			std::string const &id();
			%feature("docstring","sets a new id for the object\n\n*C++*::\n\n void setId(std::string const &id);\n\n") setId;
			void setId(std::string const &id);
			
			//Storable data management
			%feature("docstring","stores a reference to an object <o> within this object. <name> is a string used for retrieving the object reference later.\nIf <destroy> is set to true then the object <o> is explicitly destroyed (i.e. passed to the :meth:`xgui.Master.Destroy()` function) when removed from the store.\n\n*C++*::\n\n void store(std::string const &name, xgui::Object * o, bool destroy = false);\n\n") store;
			void store(std::string const &name, xgui::Object * o, bool destroy = false);
			%feature("docstring","returns an object reference previously set with the :meth:`xgui.Object.store()` method.\n\n*C++*::\n\n xgui::Object * retrieve(std::string const &name);\n\n") retrieve;
			xgui::Object * retrieve(std::string const &name);
			%feature("docstring","removes an object reference previously set with the :meth:`xgui.Object.store()` method.\n\n*C++*::\n\n void unstore(std::string const &name);\n\n") unstore;
			void unstore(std::string const &name);

			//Properties management
			%feature("docstring","gets the property specified by <name> filling the <dest> string with its value; return true if the specified property exists, false otherwise\n\n*C++*::\n\n bool set(std::string const &name, std::string const &val);\n\n") set;
			bool set(std::string const &name, std::string const &val);
			%feature("docstring","sets the property specified by <name> to the value <val>\n\n*C++*::\n\n bool get(std::string const &name, std::string &dest);\n\n") get;
			bool get(std::string const &name, std::string &dest);
			%feature("docstring","register a new property handler for the object; <prop> specifies the property name, <setter> is a pointer to the function that will be called for setting the property value, <getter> is a pointer to the function that will be called for retrieving the property value\n\n*C++*::\n\n void registerProperty(std::string const &prop,xgui::PropertySetter setter,xgui::PropertyGetter getter,bool dumpable);\n\n") registerProperty;
			void registerProperty(std::string const &prop, xgui::PropertySetter setter, xgui::PropertyGetter getter, bool dumpable);
			%feature("docstring","returns a vector of all property names of the object\n\n*C++*::\n\n std::vector<std::string> properties();\n\n") properties;
			std::vector<std::string> properties();
			%feature("docstring","returns xgui::PROPERTY_NOT_FOUND if the object doesn't have the specified property returns xgui::PROPERTY_READ_ONLY if the property is read-only returns xgui::PROPERTY_READ_WRITE if the property is read-write\n\n*C++*::\n\n \n\n") hasProperties;
			xgui::PropertyType hasProperty(std::string const &property);

			//Dynamic Objects
			%feature("docstring","returns an object given a pack string\n\n*C++*::\n\n static xgui::Object * Unpack(std::string const &obj);\n\n") Unpack;
			static xgui::Object * Unpack(std::string const &obj);
			%feature("returns a string representing the object\n\n*C++*::\n\n std::string pack();\n\n") pack;
			std::string pack();
			%feature("returns the dynamic method called <name> or NULL if the object doesn't have one\n\n*C++*::\n\n xgui::DMethod * findMethod(std::string const &name);\n\n") findMethod;
			xgui::DMethod * findMethod(std::string const &name);
			%feature("docstring","register a new dynamic method; <name> is the method name; <m> is the reference to an object that encapsulate the method\n\n*C++*::\n\n void registerMethod(std::string const &name, xgui::DMethod * m);\n\n") registerMethod;
			void registerMethod(std::string const &name, xgui::DMethod * m);
			%feature("docstring","calls a dynamic method\n\n*C++*::\n\n std::string call(std::string const &method, std::string const &p1);\n\n std::string call(std::string const &method, std::string const &p1, std::string const &p2);\n\n") call;
			std::string call(std::string const &method, std::string const &p1);
			std::string call(std::string const &method, std::string const &p1, std::string const &p2);
	};
}

%clear xgui::Object *;
%clear std::string &outvals;
